package com.ruoyi.web.controller.system;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.AnonymousAccess;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.vo.Result;
import com.ruoyi.system.domain.vo.AdminPaymentRecordQuerReqVo;
import com.ruoyi.system.domain.vo.AdminPaymentRecordQueryListRes;
import com.ruoyi.web.service.ISysPaymentRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/paymentRecord")
@Api(tags="管理端-支付记录")
public class SysPaymentRecordController {

    @Autowired
    private ISysPaymentRecordService paymentRecordService;

    @GetMapping("/list")
    @Log(title = "支付记录-列表查询", businessType = BusinessType.OTHER)
    @ApiOperation(value="支付记录-列表查询", notes="支付记录-列表查询")
    public Result<?> list(AdminPaymentRecordQuerReqVo adminPaymentRecordQuerReqVo,
                          @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                          @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
        Page<AdminPaymentRecordQueryListRes> page = new Page<>(pageNo, pageSize);
        List<AdminPaymentRecordQueryListRes> res = paymentRecordService.adminQueryList(page, adminPaymentRecordQuerReqVo);
        page.setRecords(res);
        return Result.OK(page);
    }

    @PostMapping("/redeliver")
    @ApiOperation(value="支付记录-重新发货", notes="支付记录-重新发货")
    @Log(title = "支付记录-重新发货", businessType = BusinessType.UPDATE)
    public Result<?> redeliver(@RequestBody List<Long> ids) {
        paymentRecordService.redeliver(ids);
        return Result.OK("重新发货成功：");
    }


}
